package com.nine.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.nine.dao.RoleDao;
import com.nine.entity.PageSort;
import com.nine.entity.Role;
import com.nine.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author:LouFangRui
 * @Date:2022/6/28 15:43
 */
@Service
public class RoleServiceImpl implements RoleService {
	@Autowired
	private RoleDao roleDao;
	/**
	 * 查询and模糊查询
	 * */
	@Override
	public List<Role> selectAllRole(Role role) {
		List<Role> roleList = roleDao.selectAllRole(role);
		System.out.println(roleList.toString());
		return roleList;
	}

	/**
	 * 删除
	 * */
	@Override
	public int deleteById(String[] roleId) {
		int b = roleDao.deleteById(roleId);
		return b;
	}

	/**
	 * 添加
	 * */
	@Override
	public int addRole(Role role) {
		int i = roleDao.addRole(role);
		return i;
	}

	/**
	 * 修改
	 * */
	@Override
	public int updateRole(Role role) {
		int i = roleDao.updateRole(role);
		return i;
	}

	/**
	 * 分页查询
	 * */
	@Override
	public Page findAllRole(PageSort pageSort, Role role) {
			//开始分页
			Page<Role> page = PageHelper.startPage(pageSort.getPage(), pageSort.getLimit());
			List<Role> roleList = roleDao.selectAllRole(role);
			Page listWithPage = (Page) roleList;
			return listWithPage;
	}
}